/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author TANGQUOCTUAN
 */
@Entity
@Table(name = "Foods", catalog = "TUNGA", schema = "dbo")
@NamedQueries({
    @NamedQuery(name = "Foods.findAll", query = "SELECT f FROM Foods f"),
    @NamedQuery(name = "Foods.findByFoodID", query = "SELECT f FROM Foods f WHERE f.foodID = :foodID"),
    @NamedQuery(name = "Foods.findByFoodName", query = "SELECT f FROM Foods f WHERE f.foodName = :foodName"),
    @NamedQuery(name = "Foods.findByDescription", query = "SELECT f FROM Foods f WHERE f.description = :description"),
    @NamedQuery(name = "Foods.findByPrice", query = "SELECT f FROM Foods f WHERE f.price = :price"),
    @NamedQuery(name = "Foods.findByPicture", query = "SELECT f FROM Foods f WHERE f.picture = :picture")})
public class Foods implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    @Basic(optional = false)
    @Column(name = "FoodID", nullable = false)
    private Integer foodID;
    @Basic(optional = false)
    @Column(name = "FoodName", nullable = false, length = 50)
    private String foodName;
    @Basic(optional = false)
    @Column(name = "Description", nullable = false, length = 1000)
    private String description;
    @Basic(optional = false)
    @Column(name = "Price", nullable = false)
    private double price;
    @Column(name = "Picture", length = 1000)
    private String picture;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "foods")
    private List<OrderFoodDetails> orderFoodDetailsList;
    @JoinColumn(name = "CaFoodID", referencedColumnName = "CaFoodID", nullable = false)
    @ManyToOne(optional = false)
    private CategoryFoods categoryFoods;

    public Foods() {
    }

    public Foods(Integer foodID) {
        this.foodID = foodID;
    }

    public Foods(Integer foodID, String foodName, String description, double price) {
        this.foodID = foodID;
        this.foodName = foodName;
        this.description = description;
        this.price = price;
    }

    public Foods(String foodName, String description, Double price, String picture) {
        this.foodName = foodName;
        this.description = description;
        this.price = price;
        this.picture = picture;
    }

    public Integer getFoodID() {
        return foodID;
    }

    public void setFoodID(Integer foodID) {
        this.foodID = foodID;
    }

    public String getFoodName() {
        return foodName;
    }

    public void setFoodName(String foodName) {
        this.foodName = foodName;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public String getPicture() {
        return picture;
    }

    public void setPicture(String picture) {
        this.picture = picture;
    }

    public List<OrderFoodDetails> getOrderFoodDetailsList() {
        return orderFoodDetailsList;
    }

    public void setOrderFoodDetailsList(List<OrderFoodDetails> orderFoodDetailsList) {
        this.orderFoodDetailsList = orderFoodDetailsList;
    }

    public CategoryFoods getCategoryFoods() {
        return categoryFoods;
    }

    public void setCategoryFoods(CategoryFoods categoryFoods) {
        this.categoryFoods = categoryFoods;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (foodID != null ? foodID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Foods)) {
            return false;
        }
        Foods other = (Foods) object;
        if ((this.foodID == null && other.foodID != null) || (this.foodID != null && !this.foodID.equals(other.foodID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Foods[foodID=" + foodID + "]";
    }

}
